home *** CD-ROM | disk | FTP | other *** search
/ Introducing the New Way to Shop From Home / Introducing the New Way to Shop From Home (Iceland Foods) (2003).iso / pc / MacStepbyStep.dxr / Internal_26_Jump Forward Button.ls < prev    next >
Encoding:
Text File  |  2003-01-01  |  5.5 KB  |  139 lines

  1. property myStateBehavior, myState
  2. global gNavigationButtonList
  3.  
  4. on getBehaviorDescription me
  5.   return "JUMP FORWARD BUTTON" & RETURN & RETURN & "Allows users to retrace their steps after having used the Back button." & RETURN & RETURN & "This behavior works in association with the Jump Back Button, which in turn relies on the Jump to Marker Button and/or Jump to Movie Button behaviors." & RETURN & RETURN & "These behaviors store visited markers in a global variable: gNavigationButtonList. " & "While authoring, the Jump Back Button may take you to other (unconnected) movies where you used the same behavior. " & "If you find this disconcerting, type 'clearGlobals' into the Message Window before you run your current movie." & RETURN & RETURN & "If you wish to use the Jump... " & "behaviors both on the Stage and in a MIAW, and you wish to make the content of each entirely separate, you will need to create a copy of the whole set of behaviors, and change all occurrences of the global name in all the behaviors in one set. " & "(Use the Find command, followed by the Replace All button, limiting the search to the current script). " & "Use one set of behaviors for the MIAW and the other for the Stage." & RETURN & RETURN & "PERMITTED MEMBER TYPES:" & RETURN & "Graphic members" & RETURN & RETURN & "PARAMETERS:" & RETURN & "None" & RETURN & RETURN & "ASSOCIATED BEHAVIORS:" & RETURN & "* Jump to Marker Button" & RETURN & "* Jump to Movie Button" & RETURN & "* Jump Back Button" & RETURN & "* Push Button (to alter rollover / mouseDown states)"
  6. end
  7.  
  8. on getBehaviorTooltip me
  9.   return "Use with graphic members." & RETURN & RETURN & "This behavior can only be used in conjunction with the Jump Back Button behavior, which in turn relies on the Jump to Marker Button and/or Jump to Movie Button behaviors. " & "When the user clicks on a sprite with this behavior the playback head will retrace the steps previously taken in the reverse direction by the Jump Back Button."
  10. end
  11.  
  12. on beginSprite me
  13.   Initialize(me)
  14. end
  15.  
  16. on prepareFrame me
  17.   if myStateBehavior.count() then
  18.     CheckIfActive(me)
  19.   end if
  20. end
  21.  
  22. on mouseUp me
  23.   GoForward(me)
  24. end
  25.  
  26. on Initialize me
  27.   if voidp(gNavigationButtonList) then
  28.     gNavigationButtonList = [#stack: [], #forward: [], #index: []]
  29.   else
  30.     if gNavigationButtonList.ilk <> #propList then
  31.       ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  32.     else
  33.       if not gNavigationButtonList.findPos(#stack) then
  34.         ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  35.       else
  36.         if not gNavigationButtonList.findPos(#index) then
  37.           ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  38.         else
  39.           if not gNavigationButtonList.findPos(#forward) then
  40.             ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  41.           end if
  42.         end if
  43.       end if
  44.     end if
  45.   end if
  46.   theSprite = sprite(me.spriteNum)
  47.   theBehaviors = theSprite.scriptInstanceList
  48.   myState = -1
  49.   myStateBehavior = []
  50.   call(#PushButton_GetReference, theBehaviors, myStateBehavior)
  51. end
  52.  
  53. on CheckIfActive me
  54.   forwardCount = count(gNavigationButtonList.forward)
  55.   forwardState = forwardCount <> 0
  56.   if myState = forwardState then
  57.     exit
  58.   end if
  59.   myState = forwardState
  60.   call(#PushButton_ToggleActive, myStateBehavior, forwardState)
  61. end
  62.  
  63. on GoForward me
  64.   forwardCount = count(gNavigationButtonList.forward)
  65.   if not forwardCount then
  66.     exit
  67.   else
  68.     currentMarker = [#frame: marker(0), #movie: the movieName]
  69.     gNavigationButtonList.stack.append(currentMarker)
  70.     markerToGoTo = gNavigationButtonList.forward.getLast()
  71.     gNavigationButtonList.forward.deleteAt(forwardCount)
  72.     theFrame = markerToGoTo.frame
  73.     theMovie = markerToGoTo.movie
  74.     if theMovie = the movieName then
  75.       go(theFrame)
  76.     else
  77.       go(theFrame, theMovie)
  78.     end if
  79.   end if
  80. end
  81.  
  82. on substituteStrings me, parentString, childStringList
  83.   i = childStringList.count()
  84.   repeat while i
  85.     tempString = EMPTY
  86.     dummyString = childStringList.getPropAt(i)
  87.     replacement = childStringList[i]
  88.     lengthAdjust = dummyString.char.count - 1
  89.     repeat while 1
  90.       position = offset(dummyString, parentString)
  91.       if not position then
  92.         parentString = tempString & parentString
  93.         exit repeat
  94.         next repeat
  95.       end if
  96.       if position <> 1 then
  97.         tempString = tempString & parentString.char[1..position - 1]
  98.       end if
  99.       tempString = tempString & replacement
  100.       delete parentString.char[1..position + lengthAdjust]
  101.     end repeat
  102.     i = i - 1
  103.   end repeat
  104.   return parentString
  105. end
  106.  
  107. on ErrorAlert me, theError, data
  108.   behaviorName = string(me)
  109.   delete word 1 of behaviorName
  110.   delete char -30001 of behaviorName
  111.   delete char -30001 of behaviorName
  112.   case data.ilk of
  113.     #void:
  114.       data = "<void>"
  115.     #symbol:
  116.       data = "#" & data
  117.   end case
  118.   case theError of
  119.     #invalidGlobal:
  120.       terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1"
  121.       terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum])
  122.       terror2 = "Behavior ^0 requires a global gNavigationButtonList with " & RETURN & "the following structure:"
  123.       terror2 = substituteStrings(me, terror2, ["^0": behaviorName])
  124.       terror3 = "[#stack [...], #index: [...], #forward: [...]]"
  125.       terror4 = "Current value = ^0"
  126.       terror4 = substituteStrings(me, terror4, ["^0": data])
  127.       alert(terror1 & RETURN & RETURN & terror2 & RETURN & terror3 & RETURN & RETURN & terror4)
  128.       halt()
  129.   end case
  130. end
  131.  
  132. on isOKToAttach me, aSpriteType, aSpriteNum
  133.   tisok = 0
  134.   if aSpriteType = #graphic then
  135.     tisok = 1
  136.   end if
  137.   return tisok
  138. end
  139.